
<!doctype html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width">

	<title>File catalog\controller\api\sale\cart.php | OpenCart API API</title>
	<link rel="stylesheet" href="http://localhost\opencart-master/docs/api/assets/main.css">
	<script src="http://localhost\opencart-master/docs/api/assets/main.js" defer></script>
</head>

<body class="layout">
	<div class="layout-aside">
	<div class="menu">
			<div class="menu-section">
				<h3>Namespaces</h3>
	<ul>
			<li class="menuGroup-item active">
				<a href="http://localhost\opencart-master/docs/api/namespace-Opencart.html">Opencart</a>
	<ul>
			<li class="menuGroup-item">
				<a href="http://localhost\opencart-master/docs/api/namespace-Opencart.Admin.html">Admin</a>
			</li>
			<li class="menuGroup-item active">
				<a href="http://localhost\opencart-master/docs/api/namespace-Opencart.Catalog.html">Catalog</a>
	<ul>
			<li class="menuGroup-item active">
				<a href="http://localhost\opencart-master/docs/api/namespace-Opencart.Catalog.Controller.html">Controller</a>
	<ul>
			<li class="menuGroup-item">
				<a href="http://localhost\opencart-master/docs/api/namespace-Opencart.Catalog.Controller.Account.html">Account</a>
			</li>
			<li class="menuGroup-item active">
				<a href="http://localhost\opencart-master/docs/api/namespace-Opencart.Catalog.Controller.Api.html">Api</a>
	<ul>
			<li class="menuGroup-item">
				<a href="http://localhost\opencart-master/docs/api/namespace-Opencart.Catalog.Controller.Api.Account.html">Account</a>
			</li>
			<li class="menuGroup-item">
				<a href="http://localhost\opencart-master/docs/api/namespace-Opencart.Catalog.Controller.Api.Localisation.html">Localisation</a>
			</li>
			<li class="menuGroup-item active">
				<a href="http://localhost\opencart-master/docs/api/namespace-Opencart.Catalog.Controller.Api.Sale.html">Sale</a>
			</li>
	</ul>
			</li>
			<li class="menuGroup-item">
				<a href="http://localhost\opencart-master/docs/api/namespace-Opencart.Catalog.Controller.Checkout.html">Checkout</a>
			</li>
			<li class="menuGroup-item">
				<a href="http://localhost\opencart-master/docs/api/namespace-Opencart.Catalog.Controller.Cms.html">Cms</a>
			</li>
			<li class="menuGroup-item">
				<a href="http://localhost\opencart-master/docs/api/namespace-Opencart.Catalog.Controller.Common.html">Common</a>
			</li>
			<li class="menuGroup-item">
				<a href="http://localhost\opencart-master/docs/api/namespace-Opencart.Catalog.Controller.Cron.html">Cron</a>
			</li>
			<li class="menuGroup-item">
				<a href="http://localhost\opencart-master/docs/api/namespace-Opencart.Catalog.Controller.Error.html">Error</a>
			</li>
			<li class="menuGroup-item">
				<a href="http://localhost\opencart-master/docs/api/namespace-Opencart.Catalog.Controller.Event.html">Event</a>
			</li>
			<li class="menuGroup-item">
				<a href="http://localhost\opencart-master/docs/api/namespace-Opencart.Catalog.Controller.Extension.html">Extension</a>
			</li>
			<li class="menuGroup-item">
				<a href="http://localhost\opencart-master/docs/api/namespace-Opencart.Catalog.Controller.Information.html">Information</a>
			</li>
			<li class="menuGroup-item">
				<a href="http://localhost\opencart-master/docs/api/namespace-Opencart.Catalog.Controller.Localisation.html">Localisation</a>
			</li>
			<li class="menuGroup-item">
				<a href="http://localhost\opencart-master/docs/api/namespace-Opencart.Catalog.Controller.Mail.html">Mail</a>
			</li>
			<li class="menuGroup-item">
				<a href="http://localhost\opencart-master/docs/api/namespace-Opencart.Catalog.Controller.Product.html">Product</a>
			</li>
			<li class="menuGroup-item">
				<a href="http://localhost\opencart-master/docs/api/namespace-Opencart.Catalog.Controller.Startup.html">Startup</a>
			</li>
			<li class="menuGroup-item">
				<a href="http://localhost\opencart-master/docs/api/namespace-Opencart.Catalog.Controller.Tool.html">Tool</a>
			</li>
	</ul>
			</li>
			<li class="menuGroup-item">
				<a href="http://localhost\opencart-master/docs/api/namespace-Opencart.Catalog.Model.html">Model</a>
			</li>
	</ul>
			</li>
			<li class="menuGroup-item">
				<a href="http://localhost\opencart-master/docs/api/namespace-Opencart.System.html">System</a>
			</li>
	</ul>
			</li>
			<li class="menuGroup-item">
				<a href="http://localhost\opencart-master/docs/api/namespace-none.html">none</a>
			</li>
	</ul>
			</div>

		<div class="menu-section">
			<h3>Classes</h3>
			<ul>
					<li>
						<a href="http://localhost\opencart-master/docs/api/Opencart.Catalog.Controller.Api.Sale.Affiliate.html">
							Affiliate
						</a>
					</li>
					<li class="active">
						<a href="http://localhost\opencart-master/docs/api/Opencart.Catalog.Controller.Api.Sale.Cart.html">
							Cart
						</a>
					</li>
					<li>
						<a href="http://localhost\opencart-master/docs/api/Opencart.Catalog.Controller.Api.Sale.Coupon.html">
							Coupon
						</a>
					</li>
					<li>
						<a href="http://localhost\opencart-master/docs/api/Opencart.Catalog.Controller.Api.Sale.Customer.html">
							Customer
						</a>
					</li>
					<li>
						<a href="http://localhost\opencart-master/docs/api/Opencart.Catalog.Controller.Api.Sale.Order.html">
							Order
						</a>
					</li>
					<li>
						<a href="http://localhost\opencart-master/docs/api/Opencart.Catalog.Controller.Api.Sale.PaymentAddress.html">
							PaymentAddress
						</a>
					</li>
					<li>
						<a href="http://localhost\opencart-master/docs/api/Opencart.Catalog.Controller.Api.Sale.PaymentMethod.html">
							PaymentMethod
						</a>
					</li>
					<li>
						<a href="http://localhost\opencart-master/docs/api/Opencart.Catalog.Controller.Api.Sale.Reward.html">
							Reward
						</a>
					</li>
					<li>
						<a href="http://localhost\opencart-master/docs/api/Opencart.Catalog.Controller.Api.Sale.ShippingAddress.html">
							ShippingAddress
						</a>
					</li>
					<li>
						<a href="http://localhost\opencart-master/docs/api/Opencart.Catalog.Controller.Api.Sale.ShippingMethod.html">
							ShippingMethod
						</a>
					</li>
					<li>
						<a href="http://localhost\opencart-master/docs/api/Opencart.Catalog.Controller.Api.Sale.Voucher.html">
							Voucher
						</a>
					</li>
			</ul>
		</div>
	</div>
	</div>

	<div class="layout-main">
		<div class="layout-navbar">
	<nav class="navbar">
		<div class="navbar-left">
			<ul class="navbar-links">
				<li>
					<a href="http://localhost\opencart-master/docs/api/index.html">Overview</a>
				</li>
				<li>
					
						<a href="http://localhost\opencart-master/docs/api/namespace-Opencart.Catalog.Controller.Api.Sale.html">Namespace</a>
					
				</li>
<li class="active"><a href="http://localhost\opencart-master/docs/api/Opencart.Catalog.Controller.Api.Sale.Cart.html">Class</a></li>				<li>
					<a href="http://localhost\opencart-master/docs/api/tree.html">Tree</a>
				</li>
			</ul>
		</div>
		<div class="navbar-right">
	<div class="search" data-elements="http://localhost\opencart-master/docs/api/assets/elements.js">
		<input class="search-input" placeholder="Search class, function or namespace" autofocus>
		<ul class="search-results"></ul>
	</div>
		</div>
	</nav>
		</div>

		<div class="layout-content">
	<table class="source"><tr id="1" class="source-line"><td><a class="source-lineNum" href="#1">  1: </a></td><td><span class="php-tag">&lt;?php</span></td></tr><tr id="2" class="source-line"><td><a class="source-lineNum" href="#2">  2: </a></td><td><span class="php-tag"></span><span class="php-kw">namespace</span> Opencart\Catalog\Controller\Api\Sale;</td></tr><tr id="3" class="source-line"><td><a class="source-lineNum" href="#3">  3: </a></td><td><span class="php-comment">/**</span></td></tr><tr id="4" class="source-line"><td><a class="source-lineNum" href="#4">  4: </a></td><td><span class="php-comment"> * Class Cart</span></td></tr><tr id="5" class="source-line"><td><a class="source-lineNum" href="#5">  5: </a></td><td><span class="php-comment"> *</span></td></tr><tr id="6" class="source-line"><td><a class="source-lineNum" href="#6">  6: </a></td><td><span class="php-comment"> * @package Opencart\Catalog\Controller\Api\Sale</span></td></tr><tr id="7" class="source-line"><td><a class="source-lineNum" href="#7">  7: </a></td><td><span class="php-comment"> */</span></td></tr><tr id="8" class="source-line"><td><a class="source-lineNum" href="#8">  8: </a></td><td><span class="php-kw">class</span> Cart <span class="php-kw">extends</span> \Opencart\System\Engine\Controller {</td></tr><tr id="9" class="source-line"><td><a class="source-lineNum" href="#9">  9: </a></td><td>	<span class="php-comment">/**</span></td></tr><tr id="10" class="source-line"><td><a class="source-lineNum" href="#10"> 10: </a></td><td><span class="php-comment">	 * @return void</span></td></tr><tr id="11" class="source-line"><td><a class="source-lineNum" href="#11"> 11: </a></td><td><span class="php-comment">	 */</span></td></tr><tr id="12" class="source-line"><td><a class="source-lineNum" href="#12"> 12: </a></td><td>	<span class="php-kw">public</span> <span class="php-kw">function</span> index(): void {</td></tr><tr id="13" class="source-line"><td><a class="source-lineNum" href="#13"> 13: </a></td><td>		<span class="php-var">$this</span>-&gt;load-&gt;language(<span class="php-str">&#039;api/sale/cart&#039;</span>);</td></tr><tr id="14" class="source-line"><td><a class="source-lineNum" href="#14"> 14: </a></td><td></td></tr><tr id="15" class="source-line"><td><a class="source-lineNum" href="#15"> 15: </a></td><td>		<span class="php-var">$json</span> = [];</td></tr><tr id="16" class="source-line"><td><a class="source-lineNum" href="#16"> 16: </a></td><td></td></tr><tr id="17" class="source-line"><td><a class="source-lineNum" href="#17"> 17: </a></td><td>		<span class="php-comment">// Stock</span></td></tr><tr id="18" class="source-line"><td><a class="source-lineNum" href="#18"> 18: </a></td><td>		<span class="php-kw">if</span> (!<span class="php-var">$this</span>-&gt;cart-&gt;hasStock() &amp;&amp; (!<span class="php-var">$this</span>-&gt;config-&gt;get(<span class="php-str">&#039;config_stock_checkout&#039;</span>) || <span class="php-var">$this</span>-&gt;config-&gt;get(<span class="php-str">&#039;config_stock_warning&#039;</span>))) {</td></tr><tr id="19" class="source-line"><td><a class="source-lineNum" href="#19"> 19: </a></td><td>			<span class="php-var">$json</span>[<span class="php-str">&#039;error&#039;</span>][<span class="php-str">&#039;stock&#039;</span>] = <span class="php-var">$this</span>-&gt;language-&gt;get(<span class="php-str">&#039;error_stock&#039;</span>);</td></tr><tr id="20" class="source-line"><td><a class="source-lineNum" href="#20"> 20: </a></td><td>		}</td></tr><tr id="21" class="source-line"><td><a class="source-lineNum" href="#21"> 21: </a></td><td></td></tr><tr id="22" class="source-line"><td><a class="source-lineNum" href="#22"> 22: </a></td><td>		<span class="php-var">$totals</span> = [];</td></tr><tr id="23" class="source-line"><td><a class="source-lineNum" href="#23"> 23: </a></td><td>		<span class="php-var">$taxes</span> = <span class="php-var">$this</span>-&gt;cart-&gt;getTaxes();</td></tr><tr id="24" class="source-line"><td><a class="source-lineNum" href="#24"> 24: </a></td><td>		<span class="php-var">$total</span> = <span class="php-num">0</span>;</td></tr><tr id="25" class="source-line"><td><a class="source-lineNum" href="#25"> 25: </a></td><td></td></tr><tr id="26" class="source-line"><td><a class="source-lineNum" href="#26"> 26: </a></td><td>		<span class="php-var">$this</span>-&gt;load-&gt;model(<span class="php-str">&#039;checkout/cart&#039;</span>);</td></tr><tr id="27" class="source-line"><td><a class="source-lineNum" href="#27"> 27: </a></td><td></td></tr><tr id="28" class="source-line"><td><a class="source-lineNum" href="#28"> 28: </a></td><td>		(<span class="php-var">$this</span>-&gt;model_checkout_cart-&gt;getTotals)(<span class="php-var">$totals</span>, <span class="php-var">$taxes</span>, <span class="php-var">$total</span>);</td></tr><tr id="29" class="source-line"><td><a class="source-lineNum" href="#29"> 29: </a></td><td></td></tr><tr id="30" class="source-line"><td><a class="source-lineNum" href="#30"> 30: </a></td><td>		<span class="php-var">$json</span>[<span class="php-str">&#039;products&#039;</span>] = [];</td></tr><tr id="31" class="source-line"><td><a class="source-lineNum" href="#31"> 31: </a></td><td></td></tr><tr id="32" class="source-line"><td><a class="source-lineNum" href="#32"> 32: </a></td><td>		<span class="php-var">$products</span> = <span class="php-var">$this</span>-&gt;model_checkout_cart-&gt;getProducts();</td></tr><tr id="33" class="source-line"><td><a class="source-lineNum" href="#33"> 33: </a></td><td></td></tr><tr id="34" class="source-line"><td><a class="source-lineNum" href="#34"> 34: </a></td><td>		<span class="php-kw">foreach</span> (<span class="php-var">$products</span> <span class="php-kw">as</span> <span class="php-var">$product</span>) {</td></tr><tr id="35" class="source-line"><td><a class="source-lineNum" href="#35"> 35: </a></td><td>			<span class="php-var">$description</span> = <span class="php-str">&#039;&#039;</span>;</td></tr><tr id="36" class="source-line"><td><a class="source-lineNum" href="#36"> 36: </a></td><td></td></tr><tr id="37" class="source-line"><td><a class="source-lineNum" href="#37"> 37: </a></td><td>			<span class="php-kw">if</span> (<span class="php-var">$product</span>[<span class="php-str">&#039;subscription&#039;</span>]) {</td></tr><tr id="38" class="source-line"><td><a class="source-lineNum" href="#38"> 38: </a></td><td>				<span class="php-kw">if</span> (<span class="php-var">$product</span>[<span class="php-str">&#039;subscription&#039;</span>][<span class="php-str">&#039;trial_status&#039;</span>]) {</td></tr><tr id="39" class="source-line"><td><a class="source-lineNum" href="#39"> 39: </a></td><td>					<span class="php-var">$trial_price</span> = <span class="php-var">$this</span>-&gt;currency-&gt;format(<span class="php-var">$this</span>-&gt;tax-&gt;calculate(<span class="php-var">$product</span>[<span class="php-str">&#039;subscription&#039;</span>][<span class="php-str">&#039;trial_price&#039;</span>], <span class="php-var">$product</span>[<span class="php-str">&#039;tax_class_id&#039;</span>], <span class="php-var">$this</span>-&gt;config-&gt;get(<span class="php-str">&#039;config_tax&#039;</span>)), <span class="php-var">$this</span>-&gt;session-&gt;data[<span class="php-str">&#039;currency&#039;</span>]);</td></tr><tr id="40" class="source-line"><td><a class="source-lineNum" href="#40"> 40: </a></td><td>					<span class="php-var">$trial_cycle</span> = <span class="php-var">$product</span>[<span class="php-str">&#039;subscription&#039;</span>][<span class="php-str">&#039;trial_cycle&#039;</span>];</td></tr><tr id="41" class="source-line"><td><a class="source-lineNum" href="#41"> 41: </a></td><td>					<span class="php-var">$trial_frequency</span> = <span class="php-var">$this</span>-&gt;language-&gt;get(<span class="php-str">&#039;text_&#039;</span> . <span class="php-var">$product</span>[<span class="php-str">&#039;subscription&#039;</span>][<span class="php-str">&#039;trial_frequency&#039;</span>]);</td></tr><tr id="42" class="source-line"><td><a class="source-lineNum" href="#42"> 42: </a></td><td>					<span class="php-var">$trial_duration</span> = <span class="php-var">$product</span>[<span class="php-str">&#039;subscription&#039;</span>][<span class="php-str">&#039;trial_duration&#039;</span>];</td></tr><tr id="43" class="source-line"><td><a class="source-lineNum" href="#43"> 43: </a></td><td></td></tr><tr id="44" class="source-line"><td><a class="source-lineNum" href="#44"> 44: </a></td><td>					<span class="php-var">$description</span> .= sprintf(<span class="php-var">$this</span>-&gt;language-&gt;get(<span class="php-str">&#039;text_subscription_trial&#039;</span>), <span class="php-var">$trial_price</span>, <span class="php-var">$trial_cycle</span>, <span class="php-var">$trial_frequency</span>, <span class="php-var">$trial_duration</span>);</td></tr><tr id="45" class="source-line"><td><a class="source-lineNum" href="#45"> 45: </a></td><td>				}</td></tr><tr id="46" class="source-line"><td><a class="source-lineNum" href="#46"> 46: </a></td><td></td></tr><tr id="47" class="source-line"><td><a class="source-lineNum" href="#47"> 47: </a></td><td>				<span class="php-var">$price</span> = <span class="php-var">$this</span>-&gt;currency-&gt;format(<span class="php-var">$this</span>-&gt;tax-&gt;calculate(<span class="php-var">$product</span>[<span class="php-str">&#039;subscription&#039;</span>][<span class="php-str">&#039;price&#039;</span>], <span class="php-var">$product</span>[<span class="php-str">&#039;tax_class_id&#039;</span>], <span class="php-var">$this</span>-&gt;config-&gt;get(<span class="php-str">&#039;config_tax&#039;</span>)), <span class="php-var">$this</span>-&gt;session-&gt;data[<span class="php-str">&#039;currency&#039;</span>]);</td></tr><tr id="48" class="source-line"><td><a class="source-lineNum" href="#48"> 48: </a></td><td>				<span class="php-var">$cycle</span> = <span class="php-var">$product</span>[<span class="php-str">&#039;subscription&#039;</span>][<span class="php-str">&#039;cycle&#039;</span>];</td></tr><tr id="49" class="source-line"><td><a class="source-lineNum" href="#49"> 49: </a></td><td>				<span class="php-var">$frequency</span> = <span class="php-var">$this</span>-&gt;language-&gt;get(<span class="php-str">&#039;text_&#039;</span> . <span class="php-var">$product</span>[<span class="php-str">&#039;subscription&#039;</span>][<span class="php-str">&#039;frequency&#039;</span>]);</td></tr><tr id="50" class="source-line"><td><a class="source-lineNum" href="#50"> 50: </a></td><td>				<span class="php-var">$duration</span> = <span class="php-var">$product</span>[<span class="php-str">&#039;subscription&#039;</span>][<span class="php-str">&#039;duration&#039;</span>];</td></tr><tr id="51" class="source-line"><td><a class="source-lineNum" href="#51"> 51: </a></td><td></td></tr><tr id="52" class="source-line"><td><a class="source-lineNum" href="#52"> 52: </a></td><td>				<span class="php-kw">if</span> (<span class="php-var">$duration</span>) {</td></tr><tr id="53" class="source-line"><td><a class="source-lineNum" href="#53"> 53: </a></td><td>					<span class="php-var">$description</span> .= sprintf(<span class="php-var">$this</span>-&gt;language-&gt;get(<span class="php-str">&#039;text_subscription_duration&#039;</span>), <span class="php-var">$price</span>, <span class="php-var">$cycle</span>, <span class="php-var">$frequency</span>, <span class="php-var">$duration</span>);</td></tr><tr id="54" class="source-line"><td><a class="source-lineNum" href="#54"> 54: </a></td><td>				} <span class="php-kw">else</span> {</td></tr><tr id="55" class="source-line"><td><a class="source-lineNum" href="#55"> 55: </a></td><td>					<span class="php-var">$description</span> .= sprintf(<span class="php-var">$this</span>-&gt;language-&gt;get(<span class="php-str">&#039;text_subscription_cancel&#039;</span>), <span class="php-var">$price</span>, <span class="php-var">$cycle</span>, <span class="php-var">$frequency</span>);</td></tr><tr id="56" class="source-line"><td><a class="source-lineNum" href="#56"> 56: </a></td><td>				}</td></tr><tr id="57" class="source-line"><td><a class="source-lineNum" href="#57"> 57: </a></td><td>			}</td></tr><tr id="58" class="source-line"><td><a class="source-lineNum" href="#58"> 58: </a></td><td></td></tr><tr id="59" class="source-line"><td><a class="source-lineNum" href="#59"> 59: </a></td><td>			<span class="php-var">$json</span>[<span class="php-str">&#039;products&#039;</span>][] = [</td></tr><tr id="60" class="source-line"><td><a class="source-lineNum" href="#60"> 60: </a></td><td>				<span class="php-str">&#039;cart_id&#039;</span>      =&gt; <span class="php-var">$product</span>[<span class="php-str">&#039;cart_id&#039;</span>],</td></tr><tr id="61" class="source-line"><td><a class="source-lineNum" href="#61"> 61: </a></td><td>				<span class="php-str">&#039;product_id&#039;</span>   =&gt; <span class="php-var">$product</span>[<span class="php-str">&#039;product_id&#039;</span>],</td></tr><tr id="62" class="source-line"><td><a class="source-lineNum" href="#62"> 62: </a></td><td>				<span class="php-str">&#039;name&#039;</span>         =&gt; <span class="php-var">$product</span>[<span class="php-str">&#039;name&#039;</span>],</td></tr><tr id="63" class="source-line"><td><a class="source-lineNum" href="#63"> 63: </a></td><td>				<span class="php-str">&#039;model&#039;</span>        =&gt; <span class="php-var">$product</span>[<span class="php-str">&#039;model&#039;</span>],</td></tr><tr id="64" class="source-line"><td><a class="source-lineNum" href="#64"> 64: </a></td><td>				<span class="php-str">&#039;option&#039;</span>       =&gt; <span class="php-var">$product</span>[<span class="php-str">&#039;option&#039;</span>],</td></tr><tr id="65" class="source-line"><td><a class="source-lineNum" href="#65"> 65: </a></td><td>				<span class="php-str">&#039;subscription&#039;</span> =&gt; <span class="php-var">$description</span>,</td></tr><tr id="66" class="source-line"><td><a class="source-lineNum" href="#66"> 66: </a></td><td>				<span class="php-str">&#039;quantity&#039;</span>     =&gt; <span class="php-var">$product</span>[<span class="php-str">&#039;quantity&#039;</span>],</td></tr><tr id="67" class="source-line"><td><a class="source-lineNum" href="#67"> 67: </a></td><td>				<span class="php-str">&#039;stock&#039;</span>        =&gt; <span class="php-var">$product</span>[<span class="php-str">&#039;stock&#039;</span>],</td></tr><tr id="68" class="source-line"><td><a class="source-lineNum" href="#68"> 68: </a></td><td>				<span class="php-str">&#039;minimum&#039;</span>      =&gt; <span class="php-var">$product</span>[<span class="php-str">&#039;minimum&#039;</span>],</td></tr><tr id="69" class="source-line"><td><a class="source-lineNum" href="#69"> 69: </a></td><td>				<span class="php-str">&#039;reward&#039;</span>       =&gt; <span class="php-var">$product</span>[<span class="php-str">&#039;reward&#039;</span>],</td></tr><tr id="70" class="source-line"><td><a class="source-lineNum" href="#70"> 70: </a></td><td>				<span class="php-str">&#039;price&#039;</span>        =&gt; <span class="php-var">$this</span>-&gt;currency-&gt;format(<span class="php-var">$this</span>-&gt;tax-&gt;calculate(<span class="php-var">$product</span>[<span class="php-str">&#039;price&#039;</span>], <span class="php-var">$product</span>[<span class="php-str">&#039;tax_class_id&#039;</span>], <span class="php-var">$this</span>-&gt;config-&gt;get(<span class="php-str">&#039;config_tax&#039;</span>)), <span class="php-var">$this</span>-&gt;session-&gt;data[<span class="php-str">&#039;currency&#039;</span>]),</td></tr><tr id="71" class="source-line"><td><a class="source-lineNum" href="#71"> 71: </a></td><td>				<span class="php-str">&#039;total&#039;</span>        =&gt; <span class="php-var">$this</span>-&gt;currency-&gt;format(<span class="php-var">$this</span>-&gt;tax-&gt;calculate(<span class="php-var">$product</span>[<span class="php-str">&#039;price&#039;</span>], <span class="php-var">$product</span>[<span class="php-str">&#039;tax_class_id&#039;</span>], <span class="php-var">$this</span>-&gt;config-&gt;get(<span class="php-str">&#039;config_tax&#039;</span>)) * <span class="php-var">$product</span>[<span class="php-str">&#039;quantity&#039;</span>], <span class="php-var">$this</span>-&gt;session-&gt;data[<span class="php-str">&#039;currency&#039;</span>])</td></tr><tr id="72" class="source-line"><td><a class="source-lineNum" href="#72"> 72: </a></td><td>			];</td></tr><tr id="73" class="source-line"><td><a class="source-lineNum" href="#73"> 73: </a></td><td>		}</td></tr><tr id="74" class="source-line"><td><a class="source-lineNum" href="#74"> 74: </a></td><td></td></tr><tr id="75" class="source-line"><td><a class="source-lineNum" href="#75"> 75: </a></td><td>		<span class="php-var">$json</span>[<span class="php-str">&#039;vouchers&#039;</span>] = [];</td></tr><tr id="76" class="source-line"><td><a class="source-lineNum" href="#76"> 76: </a></td><td></td></tr><tr id="77" class="source-line"><td><a class="source-lineNum" href="#77"> 77: </a></td><td>		<span class="php-var">$vouchers</span> = <span class="php-var">$this</span>-&gt;model_checkout_cart-&gt;getVouchers();</td></tr><tr id="78" class="source-line"><td><a class="source-lineNum" href="#78"> 78: </a></td><td></td></tr><tr id="79" class="source-line"><td><a class="source-lineNum" href="#79"> 79: </a></td><td>		<span class="php-kw">foreach</span> (<span class="php-var">$vouchers</span> <span class="php-kw">as</span> <span class="php-var">$key</span> =&gt; <span class="php-var">$voucher</span>) {</td></tr><tr id="80" class="source-line"><td><a class="source-lineNum" href="#80"> 80: </a></td><td>			<span class="php-var">$json</span>[<span class="php-str">&#039;vouchers&#039;</span>][] = [</td></tr><tr id="81" class="source-line"><td><a class="source-lineNum" href="#81"> 81: </a></td><td>				<span class="php-str">&#039;key&#039;</span>         =&gt; <span class="php-var">$key</span>,</td></tr><tr id="82" class="source-line"><td><a class="source-lineNum" href="#82"> 82: </a></td><td>				<span class="php-str">&#039;description&#039;</span> =&gt; sprintf(<span class="php-var">$this</span>-&gt;language-&gt;get(<span class="php-str">&#039;text_for&#039;</span>), <span class="php-var">$this</span>-&gt;currency-&gt;format(<span class="php-var">$voucher</span>[<span class="php-str">&#039;amount&#039;</span>], <span class="php-var">$this</span>-&gt;session-&gt;data[<span class="php-str">&#039;currency&#039;</span>]), <span class="php-var">$voucher</span>[<span class="php-str">&#039;to_name&#039;</span>]),</td></tr><tr id="83" class="source-line"><td><a class="source-lineNum" href="#83"> 83: </a></td><td>				<span class="php-str">&#039;amount&#039;</span>      =&gt; <span class="php-var">$this</span>-&gt;currency-&gt;format(<span class="php-var">$voucher</span>[<span class="php-str">&#039;amount&#039;</span>], <span class="php-var">$this</span>-&gt;session-&gt;data[<span class="php-str">&#039;currency&#039;</span>])</td></tr><tr id="84" class="source-line"><td><a class="source-lineNum" href="#84"> 84: </a></td><td>			];</td></tr><tr id="85" class="source-line"><td><a class="source-lineNum" href="#85"> 85: </a></td><td>		}</td></tr><tr id="86" class="source-line"><td><a class="source-lineNum" href="#86"> 86: </a></td><td></td></tr><tr id="87" class="source-line"><td><a class="source-lineNum" href="#87"> 87: </a></td><td>		<span class="php-var">$json</span>[<span class="php-str">&#039;totals&#039;</span>] = [];</td></tr><tr id="88" class="source-line"><td><a class="source-lineNum" href="#88"> 88: </a></td><td></td></tr><tr id="89" class="source-line"><td><a class="source-lineNum" href="#89"> 89: </a></td><td>		<span class="php-kw">foreach</span> (<span class="php-var">$totals</span> <span class="php-kw">as</span> <span class="php-var">$total</span>) {</td></tr><tr id="90" class="source-line"><td><a class="source-lineNum" href="#90"> 90: </a></td><td>			<span class="php-var">$json</span>[<span class="php-str">&#039;totals&#039;</span>][] = [</td></tr><tr id="91" class="source-line"><td><a class="source-lineNum" href="#91"> 91: </a></td><td>				<span class="php-str">&#039;title&#039;</span> =&gt; <span class="php-var">$total</span>[<span class="php-str">&#039;title&#039;</span>],</td></tr><tr id="92" class="source-line"><td><a class="source-lineNum" href="#92"> 92: </a></td><td>				<span class="php-str">&#039;text&#039;</span>  =&gt; <span class="php-var">$this</span>-&gt;currency-&gt;format(<span class="php-var">$total</span>[<span class="php-str">&#039;value&#039;</span>], <span class="php-var">$this</span>-&gt;session-&gt;data[<span class="php-str">&#039;currency&#039;</span>])</td></tr><tr id="93" class="source-line"><td><a class="source-lineNum" href="#93"> 93: </a></td><td>			];</td></tr><tr id="94" class="source-line"><td><a class="source-lineNum" href="#94"> 94: </a></td><td>		}</td></tr><tr id="95" class="source-line"><td><a class="source-lineNum" href="#95"> 95: </a></td><td></td></tr><tr id="96" class="source-line"><td><a class="source-lineNum" href="#96"> 96: </a></td><td>		<span class="php-var">$json</span>[<span class="php-str">&#039;shipping_required&#039;</span>] = <span class="php-var">$this</span>-&gt;cart-&gt;hasShipping();</td></tr><tr id="97" class="source-line"><td><a class="source-lineNum" href="#97"> 97: </a></td><td></td></tr><tr id="98" class="source-line"><td><a class="source-lineNum" href="#98"> 98: </a></td><td>		<span class="php-var">$this</span>-&gt;response-&gt;addHeader(<span class="php-str">&#039;Content-Type: application/json&#039;</span>);</td></tr><tr id="99" class="source-line"><td><a class="source-lineNum" href="#99"> 99: </a></td><td>		<span class="php-var">$this</span>-&gt;response-&gt;setOutput(json_encode(<span class="php-var">$json</span>));</td></tr><tr id="100" class="source-line"><td><a class="source-lineNum" href="#100">100: </a></td><td>	}</td></tr><tr id="101" class="source-line"><td><a class="source-lineNum" href="#101">101: </a></td><td></td></tr><tr id="102" class="source-line"><td><a class="source-lineNum" href="#102">102: </a></td><td>	<span class="php-comment">/**</span></td></tr><tr id="103" class="source-line"><td><a class="source-lineNum" href="#103">103: </a></td><td><span class="php-comment">	 * Add</span></td></tr><tr id="104" class="source-line"><td><a class="source-lineNum" href="#104">104: </a></td><td><span class="php-comment">	 *</span></td></tr><tr id="105" class="source-line"><td><a class="source-lineNum" href="#105">105: </a></td><td><span class="php-comment">	 * @return void</span></td></tr><tr id="106" class="source-line"><td><a class="source-lineNum" href="#106">106: </a></td><td><span class="php-comment">	 */</span></td></tr><tr id="107" class="source-line"><td><a class="source-lineNum" href="#107">107: </a></td><td>	<span class="php-kw">public</span> <span class="php-kw">function</span> add(): void {</td></tr><tr id="108" class="source-line"><td><a class="source-lineNum" href="#108">108: </a></td><td>		<span class="php-var">$this</span>-&gt;load-&gt;language(<span class="php-str">&#039;api/sale/cart&#039;</span>);</td></tr><tr id="109" class="source-line"><td><a class="source-lineNum" href="#109">109: </a></td><td></td></tr><tr id="110" class="source-line"><td><a class="source-lineNum" href="#110">110: </a></td><td>		<span class="php-var">$json</span> = [];</td></tr><tr id="111" class="source-line"><td><a class="source-lineNum" href="#111">111: </a></td><td></td></tr><tr id="112" class="source-line"><td><a class="source-lineNum" href="#112">112: </a></td><td>		<span class="php-kw">if</span> (<span class="php-kw">isset</span>(<span class="php-var">$this</span>-&gt;request-&gt;post[<span class="php-str">&#039;product_id&#039;</span>])) {</td></tr><tr id="113" class="source-line"><td><a class="source-lineNum" href="#113">113: </a></td><td>			<span class="php-var">$product_id</span> = (int)<span class="php-var">$this</span>-&gt;request-&gt;post[<span class="php-str">&#039;product_id&#039;</span>];</td></tr><tr id="114" class="source-line"><td><a class="source-lineNum" href="#114">114: </a></td><td>		} <span class="php-kw">else</span> {</td></tr><tr id="115" class="source-line"><td><a class="source-lineNum" href="#115">115: </a></td><td>			<span class="php-var">$product_id</span> = <span class="php-num">0</span>;</td></tr><tr id="116" class="source-line"><td><a class="source-lineNum" href="#116">116: </a></td><td>		}</td></tr><tr id="117" class="source-line"><td><a class="source-lineNum" href="#117">117: </a></td><td></td></tr><tr id="118" class="source-line"><td><a class="source-lineNum" href="#118">118: </a></td><td>		<span class="php-kw">if</span> (<span class="php-kw">isset</span>(<span class="php-var">$this</span>-&gt;request-&gt;post[<span class="php-str">&#039;quantity&#039;</span>])) {</td></tr><tr id="119" class="source-line"><td><a class="source-lineNum" href="#119">119: </a></td><td>			<span class="php-var">$quantity</span> = (int)<span class="php-var">$this</span>-&gt;request-&gt;post[<span class="php-str">&#039;quantity&#039;</span>];</td></tr><tr id="120" class="source-line"><td><a class="source-lineNum" href="#120">120: </a></td><td>		} <span class="php-kw">else</span> {</td></tr><tr id="121" class="source-line"><td><a class="source-lineNum" href="#121">121: </a></td><td>			<span class="php-var">$quantity</span> = <span class="php-num">1</span>;</td></tr><tr id="122" class="source-line"><td><a class="source-lineNum" href="#122">122: </a></td><td>		}</td></tr><tr id="123" class="source-line"><td><a class="source-lineNum" href="#123">123: </a></td><td></td></tr><tr id="124" class="source-line"><td><a class="source-lineNum" href="#124">124: </a></td><td>		<span class="php-kw">if</span> (<span class="php-kw">isset</span>(<span class="php-var">$this</span>-&gt;request-&gt;post[<span class="php-str">&#039;option&#039;</span>])) {</td></tr><tr id="125" class="source-line"><td><a class="source-lineNum" href="#125">125: </a></td><td>			<span class="php-var">$option</span> = array_filter(<span class="php-var">$this</span>-&gt;request-&gt;post[<span class="php-str">&#039;option&#039;</span>]);</td></tr><tr id="126" class="source-line"><td><a class="source-lineNum" href="#126">126: </a></td><td>		} <span class="php-kw">else</span> {</td></tr><tr id="127" class="source-line"><td><a class="source-lineNum" href="#127">127: </a></td><td>			<span class="php-var">$option</span> = [];</td></tr><tr id="128" class="source-line"><td><a class="source-lineNum" href="#128">128: </a></td><td>		}</td></tr><tr id="129" class="source-line"><td><a class="source-lineNum" href="#129">129: </a></td><td></td></tr><tr id="130" class="source-line"><td><a class="source-lineNum" href="#130">130: </a></td><td>		<span class="php-kw">if</span> (<span class="php-kw">isset</span>(<span class="php-var">$this</span>-&gt;request-&gt;post[<span class="php-str">&#039;subscription_plan_id&#039;</span>])) {</td></tr><tr id="131" class="source-line"><td><a class="source-lineNum" href="#131">131: </a></td><td>			<span class="php-var">$subscription_plan_id</span> = (int)<span class="php-var">$this</span>-&gt;request-&gt;post[<span class="php-str">&#039;subscription_plan_id&#039;</span>];</td></tr><tr id="132" class="source-line"><td><a class="source-lineNum" href="#132">132: </a></td><td>		} <span class="php-kw">else</span> {</td></tr><tr id="133" class="source-line"><td><a class="source-lineNum" href="#133">133: </a></td><td>			<span class="php-var">$subscription_plan_id</span> = <span class="php-num">0</span>;</td></tr><tr id="134" class="source-line"><td><a class="source-lineNum" href="#134">134: </a></td><td>		}</td></tr><tr id="135" class="source-line"><td><a class="source-lineNum" href="#135">135: </a></td><td></td></tr><tr id="136" class="source-line"><td><a class="source-lineNum" href="#136">136: </a></td><td>		<span class="php-var">$this</span>-&gt;load-&gt;model(<span class="php-str">&#039;catalog/product&#039;</span>);</td></tr><tr id="137" class="source-line"><td><a class="source-lineNum" href="#137">137: </a></td><td></td></tr><tr id="138" class="source-line"><td><a class="source-lineNum" href="#138">138: </a></td><td>		<span class="php-var">$product_info</span> = <span class="php-var">$this</span>-&gt;model_catalog_product-&gt;getProduct(<span class="php-var">$product_id</span>);</td></tr><tr id="139" class="source-line"><td><a class="source-lineNum" href="#139">139: </a></td><td></td></tr><tr id="140" class="source-line"><td><a class="source-lineNum" href="#140">140: </a></td><td>		<span class="php-kw">if</span> (<span class="php-var">$product_info</span>) {</td></tr><tr id="141" class="source-line"><td><a class="source-lineNum" href="#141">141: </a></td><td>			<span class="php-comment">// If variant get master product</span></td></tr><tr id="142" class="source-line"><td><a class="source-lineNum" href="#142">142: </a></td><td>			<span class="php-kw">if</span> (<span class="php-var">$product_info</span>[<span class="php-str">&#039;master_id&#039;</span>]) {</td></tr><tr id="143" class="source-line"><td><a class="source-lineNum" href="#143">143: </a></td><td>				<span class="php-var">$product_id</span> = <span class="php-var">$product_info</span>[<span class="php-str">&#039;master_id&#039;</span>];</td></tr><tr id="144" class="source-line"><td><a class="source-lineNum" href="#144">144: </a></td><td>			}</td></tr><tr id="145" class="source-line"><td><a class="source-lineNum" href="#145">145: </a></td><td></td></tr><tr id="146" class="source-line"><td><a class="source-lineNum" href="#146">146: </a></td><td>			<span class="php-comment">// Merge variant code with options</span></td></tr><tr id="147" class="source-line"><td><a class="source-lineNum" href="#147">147: </a></td><td>			<span class="php-kw">foreach</span> (<span class="php-var">$product_info</span>[<span class="php-str">&#039;variant&#039;</span>] <span class="php-kw">as</span> <span class="php-var">$key</span> =&gt; <span class="php-var">$value</span>) {</td></tr><tr id="148" class="source-line"><td><a class="source-lineNum" href="#148">148: </a></td><td>				<span class="php-var">$option</span>[<span class="php-var">$key</span>] = <span class="php-var">$value</span>;</td></tr><tr id="149" class="source-line"><td><a class="source-lineNum" href="#149">149: </a></td><td>			}</td></tr><tr id="150" class="source-line"><td><a class="source-lineNum" href="#150">150: </a></td><td></td></tr><tr id="151" class="source-line"><td><a class="source-lineNum" href="#151">151: </a></td><td>			<span class="php-comment">// Validate options</span></td></tr><tr id="152" class="source-line"><td><a class="source-lineNum" href="#152">152: </a></td><td>			<span class="php-var">$product_options</span> = <span class="php-var">$this</span>-&gt;model_catalog_product-&gt;getOptions(<span class="php-var">$product_id</span>);</td></tr><tr id="153" class="source-line"><td><a class="source-lineNum" href="#153">153: </a></td><td></td></tr><tr id="154" class="source-line"><td><a class="source-lineNum" href="#154">154: </a></td><td>			<span class="php-kw">foreach</span> (<span class="php-var">$product_options</span> <span class="php-kw">as</span> <span class="php-var">$product_option</span>) {</td></tr><tr id="155" class="source-line"><td><a class="source-lineNum" href="#155">155: </a></td><td>				<span class="php-kw">if</span> (<span class="php-var">$product_option</span>[<span class="php-str">&#039;required&#039;</span>] &amp;&amp; <span class="php-kw">empty</span>(<span class="php-var">$option</span>[<span class="php-var">$product_option</span>[<span class="php-str">&#039;product_option_id&#039;</span>]])) {</td></tr><tr id="156" class="source-line"><td><a class="source-lineNum" href="#156">156: </a></td><td>					<span class="php-var">$json</span>[<span class="php-str">&#039;error&#039;</span>][<span class="php-str">&#039;option_&#039;</span> . <span class="php-var">$product_option</span>[<span class="php-str">&#039;product_option_id&#039;</span>]] = sprintf(<span class="php-var">$this</span>-&gt;language-&gt;get(<span class="php-str">&#039;error_required&#039;</span>), <span class="php-var">$product_option</span>[<span class="php-str">&#039;name&#039;</span>]);</td></tr><tr id="157" class="source-line"><td><a class="source-lineNum" href="#157">157: </a></td><td>				}</td></tr><tr id="158" class="source-line"><td><a class="source-lineNum" href="#158">158: </a></td><td>			}</td></tr><tr id="159" class="source-line"><td><a class="source-lineNum" href="#159">159: </a></td><td></td></tr><tr id="160" class="source-line"><td><a class="source-lineNum" href="#160">160: </a></td><td>			<span class="php-comment">// Validate Subscription plan</span></td></tr><tr id="161" class="source-line"><td><a class="source-lineNum" href="#161">161: </a></td><td>			<span class="php-var">$subscriptions</span> = <span class="php-var">$this</span>-&gt;model_catalog_product-&gt;getSubscriptions(<span class="php-var">$product_id</span>);</td></tr><tr id="162" class="source-line"><td><a class="source-lineNum" href="#162">162: </a></td><td></td></tr><tr id="163" class="source-line"><td><a class="source-lineNum" href="#163">163: </a></td><td>			<span class="php-kw">if</span> (<span class="php-var">$subscriptions</span>) {</td></tr><tr id="164" class="source-line"><td><a class="source-lineNum" href="#164">164: </a></td><td>				<span class="php-var">$subscription_plan_ids</span> = [];</td></tr><tr id="165" class="source-line"><td><a class="source-lineNum" href="#165">165: </a></td><td></td></tr><tr id="166" class="source-line"><td><a class="source-lineNum" href="#166">166: </a></td><td>				<span class="php-kw">foreach</span> (<span class="php-var">$subscriptions</span> <span class="php-kw">as</span> <span class="php-var">$subscription</span>) {</td></tr><tr id="167" class="source-line"><td><a class="source-lineNum" href="#167">167: </a></td><td>					<span class="php-var">$subscription_plan_ids</span>[] = <span class="php-var">$subscription</span>[<span class="php-str">&#039;subscription_plan_id&#039;</span>];</td></tr><tr id="168" class="source-line"><td><a class="source-lineNum" href="#168">168: </a></td><td>				}</td></tr><tr id="169" class="source-line"><td><a class="source-lineNum" href="#169">169: </a></td><td></td></tr><tr id="170" class="source-line"><td><a class="source-lineNum" href="#170">170: </a></td><td>				<span class="php-kw">if</span> (!in_array(<span class="php-var">$subscription_plan_id</span>, <span class="php-var">$subscription_plan_ids</span>)) {</td></tr><tr id="171" class="source-line"><td><a class="source-lineNum" href="#171">171: </a></td><td>					<span class="php-var">$json</span>[<span class="php-str">&#039;error&#039;</span>][<span class="php-str">&#039;subscription&#039;</span>] = <span class="php-var">$this</span>-&gt;language-&gt;get(<span class="php-str">&#039;error_subscription&#039;</span>);</td></tr><tr id="172" class="source-line"><td><a class="source-lineNum" href="#172">172: </a></td><td>				}</td></tr><tr id="173" class="source-line"><td><a class="source-lineNum" href="#173">173: </a></td><td>			}</td></tr><tr id="174" class="source-line"><td><a class="source-lineNum" href="#174">174: </a></td><td>		} <span class="php-kw">else</span> {</td></tr><tr id="175" class="source-line"><td><a class="source-lineNum" href="#175">175: </a></td><td>			<span class="php-var">$json</span>[<span class="php-str">&#039;error&#039;</span>][<span class="php-str">&#039;warning&#039;</span>] = <span class="php-var">$this</span>-&gt;language-&gt;get(<span class="php-str">&#039;error_product&#039;</span>);</td></tr><tr id="176" class="source-line"><td><a class="source-lineNum" href="#176">176: </a></td><td>		}</td></tr><tr id="177" class="source-line"><td><a class="source-lineNum" href="#177">177: </a></td><td></td></tr><tr id="178" class="source-line"><td><a class="source-lineNum" href="#178">178: </a></td><td>		<span class="php-kw">if</span> (!<span class="php-var">$json</span>) {</td></tr><tr id="179" class="source-line"><td><a class="source-lineNum" href="#179">179: </a></td><td>			<span class="php-var">$this</span>-&gt;cart-&gt;add(<span class="php-var">$product_id</span>, <span class="php-var">$quantity</span>, <span class="php-var">$option</span>, <span class="php-var">$subscription_plan_id</span>);</td></tr><tr id="180" class="source-line"><td><a class="source-lineNum" href="#180">180: </a></td><td></td></tr><tr id="181" class="source-line"><td><a class="source-lineNum" href="#181">181: </a></td><td>			<span class="php-var">$json</span>[<span class="php-str">&#039;success&#039;</span>] = <span class="php-var">$this</span>-&gt;language-&gt;get(<span class="php-str">&#039;text_success&#039;</span>);</td></tr><tr id="182" class="source-line"><td><a class="source-lineNum" href="#182">182: </a></td><td>		}</td></tr><tr id="183" class="source-line"><td><a class="source-lineNum" href="#183">183: </a></td><td></td></tr><tr id="184" class="source-line"><td><a class="source-lineNum" href="#184">184: </a></td><td>		<span class="php-var">$this</span>-&gt;response-&gt;addHeader(<span class="php-str">&#039;Content-Type: application/json&#039;</span>);</td></tr><tr id="185" class="source-line"><td><a class="source-lineNum" href="#185">185: </a></td><td>		<span class="php-var">$this</span>-&gt;response-&gt;setOutput(json_encode(<span class="php-var">$json</span>));</td></tr><tr id="186" class="source-line"><td><a class="source-lineNum" href="#186">186: </a></td><td>	}</td></tr><tr id="187" class="source-line"><td><a class="source-lineNum" href="#187">187: </a></td><td></td></tr><tr id="188" class="source-line"><td><a class="source-lineNum" href="#188">188: </a></td><td>	<span class="php-comment">/**</span></td></tr><tr id="189" class="source-line"><td><a class="source-lineNum" href="#189">189: </a></td><td><span class="php-comment">	 * Edit</span></td></tr><tr id="190" class="source-line"><td><a class="source-lineNum" href="#190">190: </a></td><td><span class="php-comment">	 *</span></td></tr><tr id="191" class="source-line"><td><a class="source-lineNum" href="#191">191: </a></td><td><span class="php-comment">	 * @return void</span></td></tr><tr id="192" class="source-line"><td><a class="source-lineNum" href="#192">192: </a></td><td><span class="php-comment">	 */</span></td></tr><tr id="193" class="source-line"><td><a class="source-lineNum" href="#193">193: </a></td><td>	<span class="php-kw">public</span> <span class="php-kw">function</span> edit(): void {</td></tr><tr id="194" class="source-line"><td><a class="source-lineNum" href="#194">194: </a></td><td>		<span class="php-var">$this</span>-&gt;load-&gt;language(<span class="php-str">&#039;api/sale/cart&#039;</span>);</td></tr><tr id="195" class="source-line"><td><a class="source-lineNum" href="#195">195: </a></td><td></td></tr><tr id="196" class="source-line"><td><a class="source-lineNum" href="#196">196: </a></td><td>		<span class="php-var">$json</span> = [];</td></tr><tr id="197" class="source-line"><td><a class="source-lineNum" href="#197">197: </a></td><td></td></tr><tr id="198" class="source-line"><td><a class="source-lineNum" href="#198">198: </a></td><td>		<span class="php-kw">if</span> (<span class="php-kw">isset</span>(<span class="php-var">$this</span>-&gt;request-&gt;post[<span class="php-str">&#039;key&#039;</span>])) {</td></tr><tr id="199" class="source-line"><td><a class="source-lineNum" href="#199">199: </a></td><td>			<span class="php-var">$key</span> = (int)<span class="php-var">$this</span>-&gt;request-&gt;post[<span class="php-str">&#039;key&#039;</span>];</td></tr><tr id="200" class="source-line"><td><a class="source-lineNum" href="#200">200: </a></td><td>		} <span class="php-kw">else</span> {</td></tr><tr id="201" class="source-line"><td><a class="source-lineNum" href="#201">201: </a></td><td>			<span class="php-var">$key</span> = <span class="php-num">0</span>;</td></tr><tr id="202" class="source-line"><td><a class="source-lineNum" href="#202">202: </a></td><td>		}</td></tr><tr id="203" class="source-line"><td><a class="source-lineNum" href="#203">203: </a></td><td></td></tr><tr id="204" class="source-line"><td><a class="source-lineNum" href="#204">204: </a></td><td>		<span class="php-kw">if</span> (<span class="php-kw">isset</span>(<span class="php-var">$this</span>-&gt;request-&gt;post[<span class="php-str">&#039;quantity&#039;</span>])) {</td></tr><tr id="205" class="source-line"><td><a class="source-lineNum" href="#205">205: </a></td><td>			<span class="php-var">$quantity</span> = (int)<span class="php-var">$this</span>-&gt;request-&gt;post[<span class="php-str">&#039;quantity&#039;</span>];</td></tr><tr id="206" class="source-line"><td><a class="source-lineNum" href="#206">206: </a></td><td>		} <span class="php-kw">else</span> {</td></tr><tr id="207" class="source-line"><td><a class="source-lineNum" href="#207">207: </a></td><td>			<span class="php-var">$quantity</span> = <span class="php-num">1</span>;</td></tr><tr id="208" class="source-line"><td><a class="source-lineNum" href="#208">208: </a></td><td>		}</td></tr><tr id="209" class="source-line"><td><a class="source-lineNum" href="#209">209: </a></td><td></td></tr><tr id="210" class="source-line"><td><a class="source-lineNum" href="#210">210: </a></td><td>		<span class="php-var">$this</span>-&gt;cart-&gt;update(<span class="php-var">$key</span>, <span class="php-var">$quantity</span>);</td></tr><tr id="211" class="source-line"><td><a class="source-lineNum" href="#211">211: </a></td><td></td></tr><tr id="212" class="source-line"><td><a class="source-lineNum" href="#212">212: </a></td><td>		<span class="php-var">$json</span>[<span class="php-str">&#039;success&#039;</span>] = <span class="php-var">$this</span>-&gt;language-&gt;get(<span class="php-str">&#039;text_success&#039;</span>);</td></tr><tr id="213" class="source-line"><td><a class="source-lineNum" href="#213">213: </a></td><td></td></tr><tr id="214" class="source-line"><td><a class="source-lineNum" href="#214">214: </a></td><td>		<span class="php-kw">unset</span>(<span class="php-var">$this</span>-&gt;session-&gt;data[<span class="php-str">&#039;reward&#039;</span>]);</td></tr><tr id="215" class="source-line"><td><a class="source-lineNum" href="#215">215: </a></td><td></td></tr><tr id="216" class="source-line"><td><a class="source-lineNum" href="#216">216: </a></td><td>		<span class="php-var">$this</span>-&gt;response-&gt;addHeader(<span class="php-str">&#039;Content-Type: application/json&#039;</span>);</td></tr><tr id="217" class="source-line"><td><a class="source-lineNum" href="#217">217: </a></td><td>		<span class="php-var">$this</span>-&gt;response-&gt;setOutput(json_encode(<span class="php-var">$json</span>));</td></tr><tr id="218" class="source-line"><td><a class="source-lineNum" href="#218">218: </a></td><td>	}</td></tr><tr id="219" class="source-line"><td><a class="source-lineNum" href="#219">219: </a></td><td></td></tr><tr id="220" class="source-line"><td><a class="source-lineNum" href="#220">220: </a></td><td>	<span class="php-comment">/**</span></td></tr><tr id="221" class="source-line"><td><a class="source-lineNum" href="#221">221: </a></td><td><span class="php-comment">	 * Remove</span></td></tr><tr id="222" class="source-line"><td><a class="source-lineNum" href="#222">222: </a></td><td><span class="php-comment">	 *</span></td></tr><tr id="223" class="source-line"><td><a class="source-lineNum" href="#223">223: </a></td><td><span class="php-comment">	 * @return void</span></td></tr><tr id="224" class="source-line"><td><a class="source-lineNum" href="#224">224: </a></td><td><span class="php-comment">	 */</span></td></tr><tr id="225" class="source-line"><td><a class="source-lineNum" href="#225">225: </a></td><td>	<span class="php-kw">public</span> <span class="php-kw">function</span> remove(): void {</td></tr><tr id="226" class="source-line"><td><a class="source-lineNum" href="#226">226: </a></td><td>		<span class="php-var">$this</span>-&gt;load-&gt;language(<span class="php-str">&#039;api/sale/cart&#039;</span>);</td></tr><tr id="227" class="source-line"><td><a class="source-lineNum" href="#227">227: </a></td><td></td></tr><tr id="228" class="source-line"><td><a class="source-lineNum" href="#228">228: </a></td><td>		<span class="php-var">$json</span> = [];</td></tr><tr id="229" class="source-line"><td><a class="source-lineNum" href="#229">229: </a></td><td></td></tr><tr id="230" class="source-line"><td><a class="source-lineNum" href="#230">230: </a></td><td>		<span class="php-kw">if</span> (<span class="php-kw">isset</span>(<span class="php-var">$this</span>-&gt;request-&gt;post[<span class="php-str">&#039;key&#039;</span>])) {</td></tr><tr id="231" class="source-line"><td><a class="source-lineNum" href="#231">231: </a></td><td>			<span class="php-var">$key</span> = (int)<span class="php-var">$this</span>-&gt;request-&gt;post[<span class="php-str">&#039;key&#039;</span>];</td></tr><tr id="232" class="source-line"><td><a class="source-lineNum" href="#232">232: </a></td><td>		} <span class="php-kw">else</span> {</td></tr><tr id="233" class="source-line"><td><a class="source-lineNum" href="#233">233: </a></td><td>			<span class="php-var">$key</span> = <span class="php-num">0</span>;</td></tr><tr id="234" class="source-line"><td><a class="source-lineNum" href="#234">234: </a></td><td>		}</td></tr><tr id="235" class="source-line"><td><a class="source-lineNum" href="#235">235: </a></td><td></td></tr><tr id="236" class="source-line"><td><a class="source-lineNum" href="#236">236: </a></td><td>		<span class="php-comment">// Remove</span></td></tr><tr id="237" class="source-line"><td><a class="source-lineNum" href="#237">237: </a></td><td>		<span class="php-var">$this</span>-&gt;cart-&gt;remove(<span class="php-var">$key</span>);</td></tr><tr id="238" class="source-line"><td><a class="source-lineNum" href="#238">238: </a></td><td></td></tr><tr id="239" class="source-line"><td><a class="source-lineNum" href="#239">239: </a></td><td>		<span class="php-var">$json</span>[<span class="php-str">&#039;success&#039;</span>] = <span class="php-var">$this</span>-&gt;language-&gt;get(<span class="php-str">&#039;text_success&#039;</span>);</td></tr><tr id="240" class="source-line"><td><a class="source-lineNum" href="#240">240: </a></td><td></td></tr><tr id="241" class="source-line"><td><a class="source-lineNum" href="#241">241: </a></td><td>		<span class="php-kw">unset</span>(<span class="php-var">$this</span>-&gt;session-&gt;data[<span class="php-str">&#039;reward&#039;</span>]);</td></tr><tr id="242" class="source-line"><td><a class="source-lineNum" href="#242">242: </a></td><td></td></tr><tr id="243" class="source-line"><td><a class="source-lineNum" href="#243">243: </a></td><td>		<span class="php-var">$this</span>-&gt;response-&gt;addHeader(<span class="php-str">&#039;Content-Type: application/json&#039;</span>);</td></tr><tr id="244" class="source-line"><td><a class="source-lineNum" href="#244">244: </a></td><td>		<span class="php-var">$this</span>-&gt;response-&gt;setOutput(json_encode(<span class="php-var">$json</span>));</td></tr><tr id="245" class="source-line"><td><a class="source-lineNum" href="#245">245: </a></td><td>	}</td></tr><tr id="246" class="source-line"><td><a class="source-lineNum" href="#246">246: </a></td><td>}</td></tr><tr id="247" class="source-line"><td><a class="source-lineNum" href="#247">247: </a></td><td></td></tr></table>
		</div>

		<div class="layout-footer">
			OpenCart API API documentation generated by <a href="https://www.apigen.org">ApiGen dev-master</a>
		</div>
	</div>

	<div class="layout-rest">
		<div class="navbar"></div>
	</div>
</body>
</html>
